package com.wnhz.trim.plan.service.controller;

import com.wnhz.trim.common.result.HttpResp;
import com.wnhz.trim.domain.entity.Designer;
import com.wnhz.trim.plan.service.service.PlanService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;



@Api(tags = "设计部模块接口")
@RestController
@RequestMapping("/api/plan")
public class PlanController {
    @Autowired
    private PlanService ps;

    @ApiOperation(value = "添加设计师",notes = "添加设计师接口")
    @PostMapping ("addPlan")
    public HttpResp addPlan(Designer designer){
        ps.add(designer);
        return HttpResp.success("新增设计师信息完成");
    }

    @ApiOperation(value = "根据ID删除设计师")
    @DeleteMapping("deletePlan")
    public HttpResp deletePlan(int id){
        ps.delete(id);
        return HttpResp.success("删除设计师信息完成");
    }

    @ApiOperation(value = "修改设计师接口")
    @PutMapping ("updatePlan")
    public HttpResp updatePlan(Designer designer){
        ps.update(designer);
        return HttpResp.success("修改设计师信息完成");
    }

    @ApiOperation(value = "设计师全查询")
    @GetMapping("findAllPlan")
    public HttpResp findAllPlan(){
        ps.findAll();
        return HttpResp.success(ps.findAll());
    }

    @ApiOperation(value = "根据姓名模糊查找设计师")
    @GetMapping ("findByNameLike")
    public HttpResp findByNameLike(String name){
        return HttpResp.success(ps.findByNameLike(name));
    }

    @ApiOperation(value = "根据设计师ID查找")
    @GetMapping("findNameById")
    public HttpResp findNameById(int id){
        return HttpResp.success(ps.findNameById(id));
    }

}
